package com.dq.Service.Impl;

import com.dq.Mapper.HomeworkMapper;
import com.dq.Pojo.Homework;
import com.dq.Service.HomeworkService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeworkServiceImpl implements HomeworkService {
    @Autowired
    private HomeworkMapper homeworkMapper;

    @Override
    public void add(Homework homework) {
        homeworkMapper.add(homework);
    }

    @Override
    public void update(Homework homework) {
        homeworkMapper.update(homework);
    }

    @Override
    public PageInfo<Homework> findAll(Integer pageNum, Integer pageSize, Integer classId,Integer courseId, String name, String type) {
        PageHelper.startPage(pageNum,pageSize);
        List<Homework> homeworkList=homeworkMapper.findAll(classId,courseId,name,type);
        PageInfo<Homework> pageInfo=new PageInfo<>(homeworkList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        homeworkMapper.delete(id);
    }

    @Override
    public List<Homework> findByid(Integer classid, Integer courseid) {
       return homeworkMapper.findByid(classid,courseid);
    }

    @Override
    public Homework getByid(Integer id) {
        return homeworkMapper.getByid(id);
    }
}
